package com.epoint.mobileoa.personalized.epointcompany.bizlogic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.dom4j.Element;

import android.os.Message;

import com.epoint.mobileoa.bizlogic.SuperView;
import com.epoint.mobileoa.bizlogic.Task;
import com.epoint.mobileoa.datanalysis.XMLHelp;
import com.epoint.mobileoa.http.HttpHelp;
import com.epoint.mobileoa.personalized.epointcompany.model.GongzuomingxiModel;
import com.epoint.mobileoa.personalized.epointcompany.model.RZCheckHistoryMedel;

/**
 * @author liyc
 * @time 2012-3-26 下午4:36:08
 * @annotation 获取已审后的日志内容
 */
public class GetRiziNeirongTask extends Task {

	/**
	 * @param con
	 * @param param
	 */
	public GetRiziNeirongTask(SuperView con, HashMap<String, Object> param) {
		super(con, param);
	}

	@Override
	public void exectue(Message mess) throws Exception {
		String gzrzguid = getParam().get("gzrzguid").toString();
		String seamurl = getCon().fp.generateUrl("EpointGetRizhiNeirong",gzrzguid,getCon().fp.getUserguid());
		String bs = HttpHelp.getHttpBack(seamurl);
		setMessageToRefreshUI(mess, getCon(), bs);
	}
	
	public static List<GongzuomingxiModel> XmlAnalysis(String xml){
		List focs = XMLHelp.getRoot(xml).elements();
		List<GongzuomingxiModel> plist = new ArrayList<GongzuomingxiModel>();
		for (int i = 0; i < focs.size(); i++) {
			GongzuomingxiModel mt = new GongzuomingxiModel();
			Element foc = (Element) focs.get(i);
			if (foc.element("Rowguid") != null)
				mt.Rowguid = foc.elementText("Rowguid");
			if (foc.element("XiangMuMC") != null)
				mt.XiangMuMC = foc.elementText("XiangMuMC");
			if (foc.element("MissionName") != null)
				mt.MissionName = foc.elementText("MissionName");
			if (foc.element("GongZuoSJ") != null)
				mt.GongZuoSJ = foc.elementText("GongZuoSJ");
			if (foc.element("CompletePercent") != null)
				mt.CompletePercent = foc.elementText("CompletePercent");
			if (foc.element("GongZuoNR") != null)
				mt.GongZuoNR = foc.elementText("GongZuoNR");
			if (foc.element("ExtraWorkSJ") != null)
				mt.ExtraWorkSJ = foc.elementText("ExtraWorkSJ");
			if (foc.element("CheckStaWorkSJ") != null)
				mt.CheckStaWorkSJ = foc.elementText("CheckStaWorkSJ");
			if (foc.element("ExtreaStandardSJ") != null)
				mt.ExtreaStandardSJ = foc.elementText("ExtreaStandardSJ");
			if (foc.element("CheckWorkSJ") != null)
				mt.CheckWorkSJ = foc.elementText("CheckWorkSJ");
			if (foc.element("TypeID") != null)
				mt.TypeID = foc.elementText("TypeID");
			if (foc.element("TypeName") != null)
				mt.TypeName = foc.elementText("TypeName");
			plist.add(mt);
		}
		return plist;
	}

	/**
	 * @作者 liyc
	 * @时间 2012-3-29 下午6:43:20
	 * @注解
	 */
	public static List<RZCheckHistoryMedel> dplsXmlAnalysis(String xml) {
		List focs = XMLHelp.getRoot(xml).elements();
		List<RZCheckHistoryMedel> plist = new ArrayList<RZCheckHistoryMedel>();
		for (int i = 0; i < focs.size(); i++) {
			RZCheckHistoryMedel mt = new RZCheckHistoryMedel();
			Element foc = (Element) focs.get(i);
			if (foc.element("xh") != null)
				mt.xh = foc.elementText("xh");
			if (foc.element("dprq") != null)
				mt.dprq = foc.elementText("dprq");
			if (foc.element("dpr") != null)
				mt.dpr = foc.elementText("dpr");
			if (foc.element("dplr") != null)
				mt.dplr = foc.elementText("dplr");
			plist.add(mt);
		}
		return plist;
	}

}
